package com.klod.data.mapping


import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.Table

data class NewsDetailBean(
    var id:Int=1,
    var title:String="新闻标题",
    var content:String = "新闻内容",
    var date:String ="2025-3-4",
    var type:String ="0",//0没有类型 1 科技 2财经 3娱乐 4体育
    var view:Int =0,
    var like:Int =0,
    var comment:Int =0,
    var image:String ="",
    var author:String = "作者"
)



object NewsTable : Table("news_news_detail") {

    val id = integer("id").autoIncrement()
    val title = text("title")
    val content = text("content")
    val date = text("date")
    val type = text("type")
    val view = integer("view")
    val like = integer("like")
    val comment = integer("comment")
    val image = text("image")
    val author = text("author")

    override val primaryKey = PrimaryKey(id)
}

fun daoToNewsDetailModel(dao: ResultRow) =  NewsDetailBean(
    id = dao[NewsTable.id],
    title = dao[NewsTable.title],
    content = dao[NewsTable.content],
    date = dao[NewsTable.date],
    type = dao[NewsTable.type],
    view = dao[NewsTable.view],
    like = dao[NewsTable.like],
    comment = dao[NewsTable.comment],
    image = dao[NewsTable.image],
    author = dao[NewsTable.author]
)